package com.mycode.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * Created by Zengsh123 on 2020/3/11.
 */
@RestController
public class OrderController {
    // 向consul注册中心去调服务
    private static final String BASE_URL = "http://consul-provider-payment";

    private final RestTemplate restTemplate;
    @Autowired
    public OrderController(RestTemplate restTemplate) {
        this.restTemplate = restTemplate;
    }

    @GetMapping("/consumer/service/consul")
    public String get(){
        return restTemplate.getForObject(BASE_URL + "/service/consul", String.class);
    }
}
